package com.sz.sendmsg.service.impl;

import com.sz.sendmsg.dao.ManagerDao;
import com.sz.sendmsg.dao.PermissionDao;
import com.sz.sendmsg.dao.RoleDao;
import com.sz.sendmsg.entity.Manager;
import com.sz.sendmsg.entity.Permission;
import com.sz.sendmsg.service.ShiroService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.beans.PersistenceDelegate;
import java.util.List;
import java.util.Set;

@Service
@Transactional
public class ShrioServiceImpl implements ShiroService {
    @Autowired
    ManagerDao managerDao;
    @Autowired
    RoleDao roleDao;
    @Autowired
    PermissionDao permissionDao;

    public Manager getManager(String username) {
        return managerDao.getUserByName(username);
    }

    public Set<String> getRolesById(String id) {
        return roleDao.getRoles(id);
    }

    public Set<String> getRoleAll() {
        return roleDao.getRoleAll();
    }

    public Set<String> getPermsissionById(String id) {
        return permissionDao.getPermission(id);
    }

    public List<Permission> getPermission(String id) {
        return permissionDao.getPermissionByList(id);
    }

    public List<Permission> getPermissions() {
        return permissionDao.getPermissionAll();
    }
}
